Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Robert 30 posts 110 karma points
    Aug 09, 2013 @ 17:34
    Robert
    0

    umbraco.MacroEngines.DynamicNodeList does not contain a definition for [anything]

    Hi guys,

    I can't seem to get to the items below a level. I keep getting:

    'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'GetChildrenAsList'

    'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Down'

    'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Children'

    'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'Descendants'

    My website is structured like:

    Website

    -homepage

    --banners

    --Categories

    So when I'm on the homepage I want using Razor to loop round the banners. I've tried a loads of different ways but can't seem to get it working. Even just writing out the number of items under banners throws one of the above errors:

        dynamic banners = Model.HomepageCategories.GetChildrenAsList();
       
        @banners.Count()

    Above would throw:

    'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'GetChildrenAsList'

    Also stuff like this blows up:

    dynamic banners = Model.Descendants("HomepageCategories").Children;

    or

    dynamic banners = Model.Descendants("HomepageCategories").Children();

    I'm running 6.3.1, and I've install TeaCommerce but haven't done anything with it.

    Thanks

    Rob

     

     

     

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Aug 09, 2013 @ 21:19
    Jeavon Leopold
    0

    Hi Rob,

    What exactly is HomepageCategories, a property (picker) on your home page document type or a document type alias?

    Jeavon

  • Robert 30 posts 110 karma points
    Aug 11, 2013 @ 17:05
    Robert
    0

    It's a Document Type and under it are Category Document types which are what I'm trying to get to from the Homepage.

     

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Aug 11, 2013 @ 20:00
    Jeavon Leopold
    0

    Ok, I think probably the XPath method would be most appropriate for this, try:

    var banners = Model.XPath("//HomepageCategories/*");
    
  • Robert 30 posts 110 karma points
    Aug 12, 2013 @ 09:59
    Robert
    0

    This worked! Thanks.

    Why could I not look over something like:

     foreach (var item in Model.HomepageCategories.GetChildrenAsList)

     

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Aug 12, 2013 @ 12:02
    Jeavon Leopold
    100

    Great,

    Model.HomepageCategories would retrieve a property with the alias of HomepageCategories on the currentpage (which doesn't exist) and a property does not have children....

    If you have a single document type for the items you wish to select, then you could use:

    var banners = Model.Descendants("aliasOfBannerItems");
    

    However the XPath method will probably be more efficient for you

    Thanks,

    Jeavon

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies